<template>
<page-header-wrapper>
  <template v-slot:content>
      <div class="page-header-content">
        <div class="avatar">
          <a-avatar size="large" :src="headImg" />
        </div>
        <div class="content">
          <div class="content-title">
            {{ timeFix }}, {{userInfo.name}}<span class="welcome-text">{{userInfo.welcome}}</span>
            <!-- {{ welcome }} -->
          </div>
          <div> 账号: {{userInfo.account}} | 号码: {{userInfo.phone}} | 登录IP: {{userInfo.lastLoginIp}}</div>
        </div>
      </div>
    </template>
    <template v-slot:extraContent> 
      <div class="extra-content">
        <div class="stat-item">
          <a-statistic title="余额" :value="userInfo.smsBalance" />
        </div>
        <div class="stat-item">
          <a-statistic title="单价" :value="userInfo.unitPrice" />
        </div>
        <!-- <div class="stat-item">
          <a-statistic title="项目访问" :value="2223" />
        </div> -->
      </div>
    </template>
    </page-header-wrapper>
</template>

<script>
import { timeFix } from '@/utils/util'
import { RouteView } from '@/layouts'
import { baseMixin } from '@/store/app-mixin'
import { mapGetters } from 'vuex'
import AvatarModal from './AvatarModal'
import { colors, eachMap, userTypeList } from '@/utils/other'

export default {
  components: {
    RouteView,
    AvatarModal,
  },
  mixins: [baseMixin],
  data() {
    return {
      timeFix: timeFix(),
      // horizontal  inline
      mode: 'inline',

      openKeys: [],
      selectedKeys: [],

      // cropper
      preview: {},
      option: {
        img: '/avatar2.jpg',
        info: true,
        size: 1,
        outputType: 'jpeg',
        canScale: false,
        autoCrop: true,
        // 只有自动截图开启 宽度高度才生效
        autoCropWidth: 100,
        autoCropHeight: 100,
        fixedBox: true,
        // 开启宽度和高度比例
        fixed: true,
        fixedNumber: [1, 1],
      },
      userTypeList,
      pageTitle: '',
    }
  },
  computed: {
    ...mapGetters({ userInfo: 'userInfo', headImg: 'headImg' }),
  },
  mounted() {
    this.updateMenu()
  },
  methods: {
    onOpenChange(openKeys) {
      this.openKeys = openKeys
    },
    updateMenu() {
      const routes = this.$route.matched.concat()
      this.selectedKeys = [routes.pop().path]
    },
    setavatar(url) {
      let _j = {
        headImg: url,
      }
      this.$store.dispatch('UserUpdateSelf', _j).then((res) => {})
    },
  },
  watch: {
    $route(val) {
      this.updateMenu()
    },
  },
}
</script>

<style lang="less" scoped>
@import './Workplace.less';
.account-settings-info-main {
  width: 100%;
  display: flex;
  height: 100%;
  overflow: auto;

  &.mobile {
    display: block;

    .account-settings-info-left {
      border-right: unset;
      border-bottom: 1px solid #e8e8e8;
      width: 100%;
      height: 50px;
      overflow-x: auto;
      overflow-y: scroll;
    }
    .account-settings-info-right {
      padding: 20px 40px;
    }
  }

  .account-settings-info-left {
    border-right: 1px solid #e8e8e8;
    width: 224px;
  }

  .account-settings-info-right {
    flex: 1 1;
    padding: 8px 40px;

    .account-settings-info-title {
      color: rgba(0, 0, 0, 0.85);
      font-size: 20px;
      font-weight: 500;
      line-height: 28px;
      margin-bottom: 12px;
    }
    .account-settings-info-view {
      padding-top: 12px;
    }
  }
}
.ant-upload-preview {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 100px;
  border-radius: 50%;
  box-shadow: 0 0 4px #ccc;

  .upload-icon {
    position: absolute;
    bottom: 0;
    right: 0px;
    font-size: 1rem;
    padding: 0.5rem;
    background: rgba(222, 221, 221, 0.7);
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
  }
  .mask {
    opacity: 0;
    position: absolute;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: opacity 0.4s;

    &:hover {
      opacity: 1;
    }

    i {
      font-size: 2rem;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-left: -1rem;
      margin-top: -1rem;
      color: #d6d6d6;
    }
  }

  img,
  .mask {
    width: 100%;
    max-width: 180px;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
  }
}
/deep/ .ant-descriptions {
  .ant-descriptions-view {
    .ant-descriptions-row {
      .ant-descriptions-item {
        line-height: 20px;
      }
    }
  }
}
</style>
